#include "key_App.h"




#if 0
TaskHandle_t Receive_Task_Handle = NULL;
QueueHandle_t Test_Queue = NULL;



void Receive_Task(void *pvParameters)
{
	BaseType_t xReturn = pdTRUE;
	uint32_t r_queue;

	while(1)
	{
		xReturn = xQueueReceive(Test_Queue, &r_queue, portMAX_DELAY);

		if(pdTRUE == xReturn)
			printf("本次接收到的数据是%x \r\n", r_queue);
		else
			printf("数据接收错误, 错误代码: 0x%lx \r\n", xReturn);

		vTaskDelay(10);
	}
}
#endif

// 按键操作，通过按键对LED任务进行挂起恢复操作。
void KEY_Task(void *pvParameters)
{
//	BaseType_t xReturn = pdPASS;
//	uint32_t send_task1 = 0x1234;
//	uint32_t send_task2 = 0x5678;

	while(1)
	{
#if 0
		if(key_scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON)
		{
			printf("挂起LED任务 \r\n");
			vTaskSuspend(LED_Task_Handle); /* 挂起LED任务 */

			printf("开始发送消息send_data1 \r\n");
			xReturn = xQueueSend(Test_Queue, &send_task1, 0);

			if(pdPASS == xReturn)
			{
				printf("发送send_data1消息成功 \r\n ");
			}
		}
		
		if(key_scan(KEY2_GPIO_PORT, KEY2_GPIO_PIN) == KEY_ON)
		{
			printf("恢复LED任务 \r\n");
			vTaskResume(LED_Task_Handle);	/* 恢复LED任务 */

			printf("开始发送消息send_data2 \r\n");
			xReturn = xQueueSend(Test_Queue, &send_task2, 0);
			if(pdPASS == xReturn)
			{
				printf("发送消息send_data2成功 \r\n");
			}
		}
#endif
		if(key_scan(KEY1_GPIO_PORT, KEY1_GPIO_PIN) == KEY_ON)
		{  
            LED1 = 1;
            printf("KEY1按下 \r\n");
		}
		
		if(key_scan(KEY2_GPIO_PORT, KEY2_GPIO_PIN) == KEY_ON)
		{
            LED1 = 0;
            printf("KEY2按下 \r\n");
		}

		
		vTaskDelay(20);
	}
}



